/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package hibernate.dao;

import hibernate.entity.Course;
import java.util.List;
import util.HibernateUtil;

/**
 *
 * @author NDH
 */
public class CourseDAO extends AbstractDAO {

    public List<Course> readByStaffID(int id) {
        session = HibernateUtil.getSessionFactory().openSession();
        query = session.createQuery("from Courses where staffId =:id");
        return query.setParameter("id", id).list();
    }

    public Course readByID(int id) {
        session = HibernateUtil.getSessionFactory().openSession();
        query = session.createQuery("from Courses where courseId =:id");
        try {
            return (Course) query.setParameter("id", id).list().get(0);
        } catch (Exception e) {
        }
        return null;

    }
}
